
// C++ STL
#include <vector>
#include <map>
using namespace std;

#include "Timestamp.hpp"

#ifndef POLLER_HPP
#define POLLER_HPP

namespace tulun
{
    class Channel;
    class EventLoop;
    class Poller
    {
    public:
        using ChannelList = std::vector<Channel *>;
        using ChannelMap = std::map<int, Channel *>;

    protected:
        ChannelMap channels_;

    private:
        EventLoop *ownerLoop_;

    public:
        Poller(EventLoop *loop);
        virtual ~Poller();
        virtual Timestamp poll(int timeoutMs, ChannelList *activeChannels) = 0;
        virtual void updateChannel(Channel *channel) = 0;
        virtual void removeChannel(Channel *channel) = 0;
        virtual bool hasChannel(Channel *channel) const;
        static Poller *newDefultPoller(EventLoop *loop);
        void assertInLoopThread() const;
    };
} // namespace tulun

#endif